#include <fstream>
#include <iostream>
#include <vector>

struct point
{
	double x, y;
    point() {};
	point(double x, double y = 0): x(x), y(y) {};
};

double sq_dist(point& a, point& b)
{
	return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}

int main() 
{
	size_t n;
	std::cin >> n;
	std::vector<point> points;

	for (size_t i = 0; i < n; ++i) 
	{
		double x, y;
		std::cin >> x >> y;
		points.push_back(point(x, y));
	}

	int m;
	std::cin >> m;
    std::cout.precision(20);
	for (int i = 0; i < m; ++i) 
	{
		double x, y;
		std::cin >> x >> y;
		point p = point(x, y);
		size_t ans = 0;
		for (size_t j = 0; j < n; ++j) 
			if (sq_dist(points[j], p) < sq_dist(points[ans], p)) ans = j;
        std::cout << points[ans].x << " " << points[ans].y << "\n";
	}
	return 0;
}